package com.qingyun.form.validator

import com.qingyun.form.items.BaseFormItem

abstract class BaseFormValidator {
    /**
     * 校验表单
     */
    abstract fun validate(item: BaseFormItem, value: String?): FormValidatorResult

    /**
     * 校验成功
     */
    protected fun success(item: BaseFormItem): FormValidatorResult {
        return FormValidatorResult.success(item)
    }

    /**
     * 校验失败
     */
    protected fun error(item: BaseFormItem, message: String): FormValidatorResult {
        return FormValidatorResult.error(item, message)
    }
}